/*
 *此javaCode由YMS-JDBC替换工具生成，原mapper位置com.yonyou.ucf.mdf.app.isvdxq.firstpart.pandian.mapper.CheckscanMapper
 */
package com.yonyou.ucf.mdf.app.isvdxq.firstpart.pandian.mapper;

import com.yonyou.iuap.yms.api.IYmsJdbcApi;
import com.yonyou.iuap.yms.param.*;
import com.yonyou.iuap.yms.replace.CollectionUtil;
import com.yonyou.ucf.mdf.app.isvdxq.secondpart.model.CheckScanBean;
import java.sql.Types;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class CheckscanMapperImpl {
    
    @Autowired
    private IYmsJdbcApi ymsJdbcApi;

    public int insertBatch(List<CheckScanBean> insertBatch) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" insert into dxq_checkscan (`id`,`version`,`pk_temp`, `dr`,`tenant_id`,`ytenant_id`, `checkID`,`checkAreaID`,`coderfID`,`labelCount`, `product_id`,`product_sku_id`,`checkLocationID`,`storkLocationID`, `remark`,`checkUser`,`checkRemark`,`checkNum`, `checkstatus`,`scanWay`,`tagStatus`, `modify_time`,`modifier`,`create_time`,`creator`) values ");
		if (CollectionUtil.isNotEmpty(insertBatch)) {
			String separator0 = " , ";
			for (int i = 0; i < insertBatch.size(); i++) {
				CheckScanBean item = insertBatch.get(i);
				sqlBuilder.append(" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");
				parameter.addParamWithType(item.getId(), Types.VARCHAR);
				parameter.addParamWithType(item.getVersion(), Types.INTEGER);
				parameter.addParamWithType(item.getPk_temp(), Types.VARCHAR);
				parameter.addParamWithType(item.getDr(), Types.SMALLINT);
				parameter.addParamWithType(item.getTenant_id(), Types.VARCHAR);
				parameter.addParamWithType(item.getTenant_id(), Types.VARCHAR);
				parameter.addParamWithType(item.getCheckID(), Types.VARCHAR);
				parameter.addParamWithType(item.getCheckAreaID(), Types.VARCHAR);
				parameter.addParamWithType(item.getCoderfID(), Types.VARCHAR);
				parameter.addParamWithType(item.getLabelCount(), Types.VARCHAR);
				parameter.addParamWithType(item.getProduct_id(), Types.VARCHAR);
				parameter.addParamWithType(item.getProduct_sku_id(), Types.VARCHAR);
				parameter.addParamWithType(item.getCheckLocationID(), Types.VARCHAR);
				parameter.addParamWithType(item.getStorkLocationID(), Types.VARCHAR);
				parameter.addParamWithType(item.getRemark(), Types.VARCHAR);
				parameter.addParamWithType(item.getCheckUser(), Types.VARCHAR);
				parameter.addParamWithType(item.getCheckRemark(), Types.VARCHAR);
				parameter.addParamWithType(item.getCheckNum(), Types.INTEGER);
				parameter.addParamWithType(item.getCheckstatus(), Types.VARCHAR);
				parameter.addParamWithType(item.getScanWay(), Types.INTEGER);
				parameter.addParamWithType(item.getTagStatus(), Types.VARCHAR);
				parameter.addParamWithType(item.getModify_time(), Types.TIMESTAMP);
				parameter.addParamWithType(item.getModifier(), Types.VARCHAR);
				parameter.addParamWithType(item.getCreate_time(), Types.TIMESTAMP);
				parameter.addParamWithType(item.getCreator(), Types.VARCHAR);
				if (i < insertBatch.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
		}
		sqlBuilder.append(" ON DUPLICATE KEY UPDATE coderfID=VALUES(coderfID) ,labelCount=VALUES(labelCount),checkUser=VALUES(checkUser),checkNum=VALUES(checkNum) ,product_id=VALUES(product_id),product_sku_id=VALUES(product_sku_id) ,checkLocationID=VALUES(checkLocationID),storkLocationID=VALUES(storkLocationID) ,remark=VALUES(remark),checkRemark=VALUES(checkRemark) ,checkstatus=VALUES(checkstatus) ,scanWay=VALUES(scanWay),tagStatus=VALUES(tagStatus) ,modify_time=VALUES(modify_time),modifier=VALUES(modifier) ");

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }


    public int insertCheckScanList(String CheckID, String CheckAreaID, String coderfID, String labelCount, String product_id, String product_sku_id, String checkLocationID, String storkLocationID, String status, String checkNum, String scanWay, String id, String tagStatus, String remark, String checkUser, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "INSERT INTO `dxq_checkscan`( `checkID`,`checkAreaID`,`coderfID`,`LabelCount`,`product_id`,`product_sku_id`,`checkLocationID`,`storkLocationID`,`remark`,`checkUser`,`checkRemark`,`checkstatus`, `checkNum`,`scanWay`,`dr`,`tenant_id`,`ytenant_id`,`pk_temp`,`version`,`create_time`,`modify_time`,`creator`,`modifier`,`id`,tagStatus)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,?,?,'',0,now(),now(),?,?,?,?)\n";
        parameter.addParam(CheckID);
		parameter.addParam(CheckAreaID);
		parameter.addParam(coderfID);
		parameter.addParam(labelCount);
		parameter.addParam(product_id);
		parameter.addParam(product_sku_id);
		parameter.addParam(checkLocationID);
		parameter.addParam(storkLocationID);
		parameter.addParam(remark);
		parameter.addParam(checkUser);
		parameter.addParam(remark);
		parameter.addParam(status);
		parameter.addParam(checkNum);
		parameter.addParam(scanWay);
		parameter.addParam(tenant_id);
		parameter.addParam(tenant_id);
		parameter.addParam(checkUser);
		parameter.addParam(checkUser);
		parameter.addParam(id);
		parameter.addParam(tagStatus);

        
        return ymsJdbcApi.update(sql, parameter);
    }

}
